# -*- coding: utf-8 -*-
from odoo import models, fields, api

class ProductTemplatesetting(models.Model):
    _inherit = 'product.template'

    often_use = fields.Boolean(string='熱銷商品')

class ProductProductsetting(models.Model):
    _inherit = 'product.product'

    @api.model
    def name_search(self, name='', args=None, operator='ilike', limit=100):
        domain = args or []
        domain += [
            '|',
            ('name', operator, name),
            ('description', operator, name)
        ]
        return self.search(domain,order="often_use desc", limit=limit).name_get()